// 1. 向localStorage中存储token
const TOKEN_KEY = 'token_key'
const USER_KEY = 'user_key'
export const saveToken = (token)=>{
    localStorage.setItem(TOKEN_KEY, token);
}
// 2. 从localStorage中获取token
export const getToken = ()=>{
    return localStorage.getItem(TOKEN_KEY)
}
// 3. 删除token
export const removeToken = ()=>{
    localStorage.removeItem(TOKEN_KEY)
}
// 4. 向sessionStorage中存储user对象
export const saveUser = (user)=>{
    sessionStorage.setItem(USER_KEY, JSON.stringify(user));
}
// 5. 从sessionStorage中读取user对象
export const getUser = ()=>{
    return JSON.parse(sessionStorage.getItem(USER_KEY))
}
// 6. 移除user对象
export const removeUser = ()=>{
    sessionStorage.removeItem(USER_KEY)
}